import 'package:flutter/material.dart';
import 'package:my_app/app/core/theme/app_text_theme.dart';

/// empty_widget.dart
///
/// Created by fuchuanwei on Tue Apr 11 2023.
///
/// Description: 内容为空组件
///
class EmptyWidget extends StatelessWidget {
  final EmptyMode mode;

  final String? icon;

  final String? label;

  final Widget? child;

  EmptyWidget({
    super.key,
    this.mode = EmptyMode.data,
    this.icon,
    this.label,
    this.child,
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: double.infinity,
      height: double.infinity,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Image.asset(icon ?? mode.icon, width: 150),
          SizedBox(height: 20.0),
          Text(label ?? mode.label, style: tips),
          if (child != null) SizedBox(height: 10.0),
          if (child != null) child!
        ],
      ),
    );
  }
}

enum EmptyMode {
  car('assets/empty/car.png', '购物车为空'), //	购物车为空
  page('assets/empty/page.png', '页面不存在'), //页面不存在
  search('assets/empty/search.png', '没有搜索结果'), //没有搜索结果
  address('assets/empty/address.png', '没有收货地址'), //没有收货地址
  wifi('assets/empty/wifi.png', '没有WiFi'), //没有WiFi
  order('assets/empty/order.png', '订单为空'), //订单为空
  coupon('assets/empty/coupon.png', '没有优惠券'), //没有优惠券
  favor('assets/empty/favor.png', '无收藏'), //	无收藏
  permission('assets/empty/permission.png', '无权限'), //无权限
  history('assets/empty/history.png', '无历史记录'), //无历史记录
  news('assets/empty/news.png', '无新闻列表'), //无新闻列表
  message('assets/empty/message.png', '消息列表为空'), //消息列表为空
  list('assets/empty/list.png', '列表为空'), //列表为空(通用)
  data('assets/empty/data.png', '数据为空'); //数据为空(默认，通用)

  final String icon;
  final String label;
  const EmptyMode(this.icon, this.label);
}
